package mulegame;

import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.*;

/**
 * Makes resources box at bottom of page and sets values according to current player
 * @author AREA 29
 *
 */
public class Resources extends JPanel{
    private JLabel money, caffine, beans, food;
    /**
     * makes the resources box at bottom of page with user info for money, beans, caffeine, and food
     */
    public Resources(){
        super();
        setLayout(null);
        setBorder(new TitledBorder(null, "Resources",
                    TitledBorder.LEADING, TitledBorder.TOP, null, null));
        setBounds(235, 494, 432, 93);
        
        //make and add the money label
        JLabel curr = new JLabel("Money:");
        curr.setHorizontalAlignment(SwingConstants.LEFT);
        curr.setForeground(Color.BLACK);
        curr.setFont(new Font("MV Boli", Font.BOLD, 18));
        curr.setBounds(10, 16, 77, 35);
        add(curr);
        
        money = new JLabel();
        money.setHorizontalAlignment(SwingConstants.RIGHT);
        money.setForeground(Color.BLACK);
        money.setFont(new Font("MV Boli", Font.BOLD, 18));
        money.setBounds(89, 16, 104, 35);
        add(money);
        
        
        //make and add the beans label
        curr = new JLabel("Beans:");
        curr.setHorizontalAlignment(SwingConstants.LEFT);
        curr.setForeground(Color.BLACK);
        curr.setFont(new Font("MV Boli", Font.BOLD, 18));
        curr.setBounds(10, 47, 70, 35);
        add(curr);
        
        beans = new JLabel();
        beans.setHorizontalAlignment(SwingConstants.RIGHT);
        beans.setForeground(Color.BLACK);
        beans.setFont(new Font("MV Boli", Font.BOLD, 18));
        beans.setBounds(73, 47, 120, 35);
        add(beans);
        
        
        //make and add the caffine label
        curr = new JLabel("Energy:");
        curr.setHorizontalAlignment(SwingConstants.LEFT);
        curr.setForeground(Color.BLACK);
        curr.setFont(new Font("MV Boli", Font.BOLD, 18));
        curr.setBounds(244, 16, 77, 35);
        add(curr);
        
        caffine = new JLabel();
        caffine.setHorizontalAlignment(SwingConstants.RIGHT);
        caffine.setForeground(Color.BLACK);
        caffine.setFont(new Font("MV Boli", Font.BOLD, 18));
        caffine.setBounds(318, 16, 97, 35);
        add(caffine);
        
        
        //make and add the food label
        curr = new JLabel("Food:");
        curr.setHorizontalAlignment(SwingConstants.LEFT);
        curr.setForeground(Color.BLACK);
        curr.setFont(new Font("MV Boli", Font.BOLD, 18));
        curr.setBounds(244, 47, 77, 35);
        add(curr);
        
        food = new JLabel();
        food.setHorizontalAlignment(SwingConstants.RIGHT);
        food.setForeground(Color.BLACK);
        food.setFont(new Font("MV Boli", Font.BOLD, 18));
        food.setBounds(318, 47, 97, 35);
        add(food);
        
    }
    /**
     * sets values of money, beans, caffeine, and food based on each player
     * @param p player
     */
    public void usePlayer(Player p){
        money.setText("$" + Integer.toString(p.getMoney()));
        beans.setText(Integer.toString(p.getOre()));
        caffine.setText(Integer.toString(p.getEnergy()));
        food.setText(Integer.toString(p.getFood()));
    }
}
